refactor: place value parsing code in function