add whole code for dynamic controller