Issue #10 fixed

Preventing crash by moving the deletion of expired doses outside of the
loop.