updated to use various helper functions