lotsa logic and tests