Moved some functions to a utils file