add unspent function and comment