Refactor compileImage method to own Object