sql script corrected 3 and tested