Simplify the implementation and provide more debug