bit of a refactor