moved cast to int outside of calculation