template code is now pretty much cleaned up