adding optimization stuff for stoc prog