Would you be able to rewrite this in Kotlin for me?