improved performance, refactored model