make saveTransaction a bit more idiomatic
refactor for clarity and to simplify saveTransaction