functions for building the bracket