[FIX] fixed sam2matrix