Removing redundant anonymous functions