Implementation of GHS algorithm