refactor some of the handler