Refactored helper functions into separate file.