Tydiing the code a bit