code from google code lua-app