bugfix to sorting