refactored it a bit so it's more interesting