moved error printout to stderr