add box calculation routine