Refactor

removed console.log and trailing white spaces. refactored code.