started integration of automatic sorting -- works ok