added switch case to determine port