more elegant way of handling https://github.com/JuliaLang/julia/issues/6264