added my method for the algorithm