Refactoring of util code