Added loading image, cleaned code