fixes to the lost algorithm