Fixing the null pointer error