add Error Handling for endLoc and startLoc