bug fix and main method added