updated version with variables - still have problems setting the correct graph to use in the admin panl