Fix for the undefined direction variable.