additional utils and algorithm