Added null check for reason