Proper random template generation and returning