fixed the 99-9=9 issue which was caused by the logical of the last few lines int compvalue()