How can I take a value from a previous value?