fixed nasty pointer bug