sorted storage and added algorithm