added helper functions to clean up code