Refactor Onclick Method