Changed and made some optimization.