fixed bug in main method