There are two issues in these two lines of if statements. 
 - (key === null) is redundant since you still need to check token anyway.
 - token.string is called before checking token.

So we can combine the two if statements here.