Here you're using $dir and at line 32 you're using {$IP} - it will be better with consistency