refactor declToLua function