fixing null pointer exception