Moved common helper functions to a global module pattern