refactor, added functionality