rearrange and improve documentation