cleaned code and fixed image display