solving pointer bug