added payload length validation