Changed code to be more "Swift style"