Checked and tested logic.