logic implementation