refactored workflow skeleton
updated SQL script