refactoring
fixed lock bug