add layout docs, example and refine code