Made the solutions clearer with explicit type declarations.