Refactor code into new function image_path()