added transactions
Cleaned up code