Fixed bug in loadImage method