move function to better context