refactor out engine work