Implementing the -g command