Refatoring Main.