Fixed parameter checking logic; output error to stderr instead of stdout