working serial version