changed read packet so it doesn't use select. Call moved before read packet