changed gib to be more modular for use in other python scripts