Version 0.1 - please see the comment on the top of the code for further description