refactored whole thing, works now