make it work, needs a bit of refactor