Edited the code and added most of the missing required things.