resolving null pointer exception