write type sign of main algo.
changed mind about type signature of algo.
rename fns.