rectified for integer elements, code optimized