added onPage event handler, fixed minor bug