Update main.lua

better velocity handling