removed small bugs in the code