Code is working better now