First implementation of base conversion