bug fix for ids ordering