code optimized

subscription logic complete