debug and refactering