1) renamed functions and added helper functions