Simplified part of the algorithm