Completed logically. Needs debugging and testing.