Converted to Kotlin