fixing input and leaks