added optional tabletop surface detection