implemented synchronized operations, made indices synchronized