move parsing to a function