Sorted out overflow issue with templates