added nil check to avoid problems with blank params