Made the assert section into a loop to clean up needlessly verbose code.