horner reimplementation