edited to work as console app