Improve Code

I have done this part of improvement. Please check and merge.