removed extra functions and made more modular