Move helper functions to header file