At this stage it works for me, but the code is a mess, options are not clearly defined. Will refactor later.