partition rewritten and some minor changes