ERT-437: Fixed spelling error lamda -> lambda
ERT-437: Moving code around to increase readability and reduce duplication.