fixing finished detection