bugfix through pseudocode