Implemented some pseudocode.