fixed bugs in controller