Fixed a crazy bug?? and also refactored to know varaibles