sorting error fixed