Modified code a little