Refactoring the image picker