working partition function
finish p2.2.1