added checkGlError function