changed curly brackets with end*** statements