fix image lookup logic