Based on a question on StackExchange, please find a solution below. We have not tested this, but it was a quick solution by: the_dramatist and kinda looks right. Please test!