Implementation of the pseudo-code program