Better scala coding