Updated to use ranges