tidied up the method to display images to make the code more portable