Altered code to try and fix image display problem