Updated with working code, forgot to commit as I went along.