updated shader with stability check