A Range Based Localization Algorithm For Wireless Sensor Networks