fixed bug: $log not defined