added printf to figure out why it is slow and there are duplicate outputs