re-structured workflow to be more maintainable and reliable