The `504` is a bit unmaintainable here as it's actually a completely different block of code that does this.