beginning of pseudocode implementation