Improvements to the box snippet by Sergey Alexandrov