added errno debugging