Main is done, added helper functions