fixed bugs with pointers