Updated the code a bit