refactored and moved some methods to utils.py