simplified algorithm