Fixed bug. EndTime was preventing the loop from continuing further.