There must be some indexing error. values in Eij not set correctly