Rewrite of Code (Glenn's half)