moved some code from Beans to Controller where it belongs