refactored utils.