chdir() moved under variables declaration.