code re-write