First logic implementation and testing.