changed to binary sort instead of elem - check performance