code refactoring, implemented model