Minor refactoring and using inbuilt function check of luaj which will emit a LuaError rather than the old IllegalStateException.