changed back to jeresig implemtation