Perhaps a more elegant template solution