code for using learned weights