Just refactor. refer to https://gist.github.com/kachick/4728444