Fixed annoying typo.
Take out unnecessary nested loop.
Type checking on endpoint paths.