algo 5 small modification