neatened up functions and made more terse
refactored completely to rely only on output from the oracle