(refactor) handler and cleanup