fixing nullpointerexception in controller