tweaking paperclip
refactoring from the original rishighan.com