Removed duplicated code by extracting things into separate methods
Added missing statement to call completion block in one of the branches