working version with templates loading