fix wrong endpoint logic