Organized the utility functions more sensibly