correctly use typeof to check wheter transaction is being created or updated