Move value parsing into function