refactored loadModel for file and buffer