Fixed bug in function, corrected variable class