The missing } was my copy paste error when converted into indented code and is now solved. Thanks for pointing that out.