Bug fix attempt (checking for &s)

Adding checks to make sure that there is an & in the prefix in the while loop and before the while loop.