re-write TP handler, removed index variable, made it a bit easier to understand.

Signed-off-by: Sleaker <sleaker@gmail.com>