implemented model loading from postgres