Fixing dereferencing bug