billeraLee function works better, but not perfectly