re-factor base.lua