added security filters and cleaned up code