refactored fns