Move some methods from routes to models