refining handler loop