Moved logic into reusable handlers.