Modified Pad function to improve safety.