Implemented a VERY SLOW safeButtonCounter

EXTREMELY SLOW. LAGS A LOT. USES N^4 OPERATIONS.