Made minor changes nothing related to actual algorithm