move function outside