added transaction and validation of input