Simplified code. Got rid of transitions because they were confusing.