added partition utility function