Bug fix for onClick event