Added function to check solution