Revised the result() and symbol() functions

Made the algorithms much more efficient.