Added lock instantiation, has bug