Modularity is a widely used measure for evaluating community structure in networks. The definition of modularity involves a comparison between the observed network and a null model, which serves as a reference. To make the comparison significant, this null model should characterize some features of the observed network. However, the previously used null models are not good representations of real-world networks. A common feature of many real-world networks is similarity attraction, i.e., nodes that are similar have a higher chance of getting connected. We propose a new null model that captures this feature. Based on our null model, we create a unified measure Dist-Modularity, which incorporates the famous Newman-Girvan modularity as a special case. We use three examples to demonstrate that Dist-Modularity is useful in detecting 1) the multi-resolution communities and 2) the geographically dispersed communities.