Added algo 6