refactor, add logic for handlers