added some guarding for parameters