added dynamic port listening to main .js file