reorganizing helper functions