move core logic into handler class