added filtering from input + bug fixes