place main in function