Use List's headOption to increase readability.

Use more idiomatic scala code.