fixed an error and added test sample for double