refactored things a bit to make it actually work