Must be a better way to do this, but I struggled to find one.