small refactor
added sample input detection