incorporated some of yuval's suggestions