Check for null

avoids nullpointer exception

Author: Shockolate