moved image code to relevant block