Refactor retrieval of image path