This code is better and more reliable