functionize call code
multiple end statments confusing