Completed convert subroutine, and implemented prototype to test it