added offset matrix. needs retesting and debugging