Indentation, moved functions out of do block