a more robust solution based on trobertson's feedback