Preventing null pointer