Changed function names and made helper functions for readability