implemented rectify, have not tested yet