todo: implement program direction in if and loop