Changed process sam function.