work in progress with refactor!