modified code to be less code-y