Code cleanup for imageview to load images safely