Adding additional tests and main algorithm for decision making.