added invalid argument check