Changed the order of the functions and restructured a bit. Added isPerfectSquare.