refactored into mvc