Fix error by enclosing onclick method