Moved helper functions to class and made static