Correct condition when selecting api endpoint