Fixed warning: operation on ‘currentDirection’ may be undefined.