corrected bug in create port function, debugged and working