fix chunk.apply and add documentation