This is pretty usless imo, but a good attempt. Although you do not need all the slashes (/)
And a few if statements to check if the %vars are set or not etc.