added a generalized merge_tile method