more code for algorithm