Add green count and improve code organization