tidied up LionelsPoser20120326 by putting the test for perfect square in a function