added some argument checking