fixing null pointer scenario