moved helper functions