refactored, test input added