Moved some helper functions to utils