Ensuring atomicity using LUA scripts