This is the updated code; forgot to commit, mea culpa.