more modular
added more debugs