updated code a bit
working sort off