structure changes and npe fix