Refactored some utility functions into Utils