Moved helper functions to prototype