added most code