fix Bugs in onclick handler