cleaned code and made some change