factoring ast