replaced 'einsum' to a more readable and faster operation