Improve this code to allow layers like 'blur' to work.