modifed for sharding