added synchronization (not tested)