refactored functions