Fixing null pointer