Added initial spatial filtering function