Correct casting and variable referencing, Equals method now works