added log and sort