implement working chunk function