added some argument checks