implementing recursive lock