Dir rearrangement
Division by zero fixed