refactored it!