Added extra sorting conditions.