Edited the code as per @eXpl0it3r's comments.