2 stage SLD coding complete, not tested yet