Implemented basic error detection