Removed Duplication

Removed all duplicate code and added it into a category on UIView