fixed. Also converted variables from int -> long