Added prevention infinite loop if wrong template
Removed unnecessary console.logs
Get rid of infinite while completely
Merge pull request #9 from schmooser/master

Added prevention infinite loop if wrong template