Fixed variable logic

Fixed the logic from processing variables, tested and is running
correctly. Added the processing of global attributes which is working
just yet.