added some parameter checks