added switches and broke up functions