fix wrong click handler call and add some additional checks for the future