fixed a bug in generatePayload() in which leading 0s were not added to the payload