refactor back to a more object orientated approach