added comments, moved ref into onclick (memory mngmnt)