Update Main.java

Improved some code.