attempt at optimised count characters
count characters optimised seems to be working