fixed bug in security routing module, better error handling