Added null pointer verification