Updated func in swift way.