Refactoring getContent function