improved exception handling
added required synchronization