main gem code