- split into smaller functions - add type hints - get rid of unnecessary db calls and loops - add docstrings for functions