updated with atomic ops