initial scala impl