moved functions around - no changes - only for view