compleate main func
add print functions
fix synchrinization with output