In indoor location-based systems, there are many important design considerations including scalability, privacy, and performance of localization. Among these considerations, accuracy is the most important factor that dominates the performance of localization. The accuracy of a location-based system is determined by receiving information from multiple beacon nodes. However, the increment of the number of deployed beacon nodes results in a lot of collisions and much interference among signals, and it can degrade the performance of the location-based system. In this paper, we propose a localization scheme based on both the law of cosines and on-demand beacon management mechanism. In our localization scheme, based on the law of cosines, only two beacon nodes are deployed to estimate the location. The on-demand beacon management mechanism has been proposed in this paper to minimize collisions and interference. This mechanism can also increase the probability of transmission from the nearest beacon and reduce error probability. Our simulation results show that the proposed scheme improves accuracy even though it uses a small number of sensor nodes and achieve a lower error rate than that of the traditional location-based system.