cleaned up helper functions