api complete, refactored model logic