implement lock logic