Bug fixes

Fixed bug by converting to numbers. I think there is a better way but I
can’t see it. Added comments