Implements error function