converting code to scala. project is currently broken as a result.