Added more checks on g_a and g