added some exception handling and transaction class