Reduced Pad function and fixed small indentation mistake.