optimize ranges