Update err statements and moved parseString to a separate function