Modified the code a little