bug fixes in the code