refactored common code in boxes