use .image property instead of .dir and if checks
put .dir back in if you need it tho