partly implement SAP (test finished)