Added lock function