reconstruct the code, add CompositeImage func