Moving some conditional logic from database into web server.