added a check for null in checkgl, #3