refactored util method