better error handling in dynamic controller