better aproach on thread saftey