debugging conditions added, isPerfectSquare fixed