Added checking for a finished state