change algorithm
write revised