changing the if statements to make sure the -1 works