added gl error checks