removed bugs in code