Removed weird global variables, fixed bugs. works with whole numbers, shouldn't error out