Refactor ml