Updated code from Muhammad Arfeen (as a test)