added smaller psuedocode