Added some code. It is ugly. Mark point because about to add some other items to handle some tasks