Algorithm 4 Class