refactored utils