Fix use of undefined var
Extract routes into separate module