added the ability to change the placement from top to bottom if top space is insufficient and similiar to other cases