implement stack & add some UTs & refactor code