added a ranged version and tested