added code to filter keys + formatting changes