Added some logic to transactions