added automatic sorting