moved gcap to functions