add pending information and clean up the code