refactor code quite a bit.