merging  logic part with drawing part