refactor datauri method