Turn serve into a function + support ports