Half refactored (somehow runs still)