refactored levelstate with factory