added some checks to make sure that there are no pending transactions before doing certain actions