refactored util functions