added closing bracket before else in the API example