edge case where end comes first