got the correct output. All that is left to do is fully test it with other inputs and clean up the code