moved util code to a more central location