more debug
split common code to seperate class