Changed script to use Q promises