Perhaps, it'd be better to rewrite this as a while loop?