borrowed some ideas from kingtak and continued to fix challenge code