Perhaps change this to a while loop?