better code for line formula