improving server.lua for better functionality