fix issues related to sorting