added edge case for one element case.