evaluate mostly working, pseudocode implemented