add else clause to prevent double results

we can either return an error or return the data, but not both