abstract out the weight functions for step4