Refactored template a bit, but it's still awkward