extract prepare().
Merge pull request #27 from axsh/remove-unnecessary-code

extract prepare().