the basic logic part is done