Make function synchronized