Fixed cannot read property button of undefined upon clicking