Refectoring

Made program shorter.