Move code to hook_entity_view()