Goel solved the output problem, refactoring