fix issues with refactored code pretty much just not working