refactored the old controller