fixed nasty bug -rmag