added helper functions and test