Added conditition to check whether ranger exists