bug fixing in progress: 2D loop is okay now