updated swift code