Fixed threshold function

Fixed threshold function
started removing function implementations out of callbacks