cleaning scala code