removed some debug functions. added imput checks