Fixed transient undefined variables in main controller