The string parsing below is quite confusing and does not feel right. Is there any possible way we can do this without string parsing?