appointment logic