added several argument checks and raise an error if they are not met