Cleaning up parsing logic