Tweaked latest code