Refactor getContent function