more code, added checkboxes and simple control algorithms