Refactor JS code and remove aws-s3