Improved template specialization