added dipole orientation code