added input lenght checking, mydebug code