Fixing the indefinite running

Fixed the indefinite running problem