attempted to improve indentation... still lots more work