fixed terminating bug