made script better and made it work