switched to stable sort