added checking for endpoints