Wrote literally the worst code I have ever written but it works and solves the problem. Needs to be refactored into a recurisvely called response handler to avoid violating DRY