fixing pointer bug