variable dir was being set too much