pseudocode and some functions