Cleaned some redundant functions by using closures