Basic logic completed

needs to be refined