get rid of perror() calls, use ERROR() instead