refactor some things
add transactions