Fixed original code and padding issue