Reworked my code completely