made sorting part of initialization