Tidied solution