Cleaning and Modification

cleaning the code with some modification