refactor backend datastore to use sorted sets