simplify onclick function