End day loop problem fixed