Fixed error. variable scope
Fix to get the correct value from the options table and some cosmetic changes