moved expression parsing to a separate function