readlink can sometimes retrurn undef, even if -s is true, so make a safety check