figuring out end point