completed script, adding unit testing