moved handler code to main route