fixed algorithm; changed radio groups to switches