changed template code to account for empty databse