Made some refactoring changes to simplify some methods