Check for null

Avoids NullPointerException