set last element if there are elements - fixes out of range error with older browsers