refactored to add intermediate state code for act 1