Fixed string cast, and use right variable for template