would be good to check if tx != NULL here?