switch to f# implementation