utility codes and algorithm test