Move some executin from main to method