semi-finished simple algorithm
first crack at controlling script