(Sorry posted the above early by accident, please see the update. Excuse any Ruby errors too, hope you get my point though! :) )