added 'elems--;' back