refactor gaussian filter code