cleaned up the solution a bit to look nicer