Fixing template selection issue