sam - changed logic