rearranged things and added docs