Code Improve

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