added globals and integraed it