improved compute()