Refactor to remove onClass overhead