Refactored the code and removed un-necessary items