Separate code to it's own method.

Signed-off-by: crynobone <crynobone@gmail.com>