Updated versions with padding handling + class oriented version