modded swift code for beta 6