We should put this into a different function and have both places in the code use it.