tap handling logic