change util method signature for better consitency with others
refactored code for greater simplicity