moved image loading code into separate file