Can refactor this and https://github.com/mozilla/fireplace/pull/430/files#diff-37f87469c175d045da60115a59a5eb79R87 into a function