Added a simple filter and more error handling