prob14 and lib functions