ugly-fixed bug in result ordering