made some fixes in the code