move out some of the helper functions