some pointers checking, still bugged