Fix var and add code to lib