added more statistics and clean code