fixed optimization bug (added too many unnecessari if statements)
optimization works now - planning verification of purity