Updated code to make it more succinct.