move function to proper location