solution method
checking correct solution