Refactored to actually work!