FIXED ALL THE THINGS!!! WORKS COMPLETELY. Output is different from given output however.