Fixed casting errors with my previous commit