For estimating the seismic demand of buildings, most seismic design provisions permit conducting linear and nonlinear response history analysis. In order to obtain reliable results from response history analyses, a proper selection of input ground motions is required. In this study, an accurate algorithm for selecting and scaling ground motions is proposed, which satisfies the ASCE 7-10 criteria. In the proposed algorithm, a desired number of ground motions are sequentially scaled and selected from a ground motion library without iterations.