modified calculation of potential field and added visualization code