move helper function to where used