move image adding to separate function