          input,
          output,
          z_index,
-         %{x_index: x_index, y_index: y_index, x_pos: x_pos, y_pos: y_pos, tile_size: tile_size}) do
+         %{x_index: x_index, y_index: y_index, x_pos: x_pos, y_pos: y_pos}) do
 
     {
-    "mkdir -p /imageroot/wes/#{output}/#{z_index}/#{x_index}/#{y_index}",
-    "convert"
-    <> " /imageroot/wes/#{input}"
-    <> " -crop #{tile_size}x#{tile_size}+#{x_pos}+#{y_pos}"
-    <> " -background transparent"
-    <> " -extent #{output_tile_size}x#{output_tile_size}"
-    <> " /imageroot/wes/#{output}/#{z_index}/#{x_index}/#{y_index}.png"}
+      "mkdir",
+      [
+        "-p", "/imageroot/wes/#{output}/#{z_index}/#{x_index}"
+      ],
+      "convert",
+      [
+        "/imageroot/wes/#{input}",
+        "-crop", "256x256+#{x_pos}+#{y_pos}",
+        "-background", "transparent",
+        "-extent", "#{output_tile_size}x#{output_tile_size}",
+        "/imageroot/wes/#{output}/#{z_index}/#{x_index}/#{y_index}.png"
+      ]
+    }
   end
 
   defp create_template(size, output_tile_size) do

    size = 6000
    tile_size = 256

    commands = Enum.flat_map(create_template(size, tile_size), fn {entries, z} ->
      Enum.map(entries,
        fn entry ->

          make_commands(tile_size, "6c5f936b-dba9-bf57-b681-5fc292e00e0b.jpg","6c5f936b-dba9-bf57-b681-5fc292e00e0b",z, entry)

        end)
    end)

      if run != :ok do
        nil
      else
        tmp = calc_template(current_size, output_tile_size, scale_factor)
        template = {current_size, List.flatten(tmp)}
        if current_size < output_tile_size do
          {template, {:halt, current_size, scale_factor*2}}
        else
