added check if in transaction to commit