fix logic in writing of shaders