Cleaned up code with 'private val' for state array