implemented bitstuffing and padding