Removed code redundancies and cleaned code
Added descriptions for each function in the code