Merged all the code to Final.java