Changing castOnce to explicit function