Modified problem 3 to not use charcodes