Lock save method to prevent race conditions