Remove duplication by using `return` function to pack result into IO type