added averaging and subtracting