added characterAt function