added dynamic payload length feature