Refactor Handler code a bit