Refactoring utility functions out of the main files