greatily simplified my solution using filter