if/fi spacing important. add debugging logs