Using templates & bug fixing