Partially migrated to scala