move function to connection