Fixed if statement on endpoint nil check