Refactored more code, still error