Removing unwanted code from controller