Fixed gpub function