fixed the controller logic, garbage collection