Switched order of code in val method