Thank to @Someprogrammerdude and @AndersK, I could reajust my thoughts and correct the code. Please refer to the comments above. Thanks again!