Move some code as private method and add a small debug

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